package io.renren.modules.work.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.work.entity.ScStocktranEntity;
import io.renren.modules.work.service.ScStocktranService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 库存交易
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-24 22:24:59
 */
@RestController
@RequestMapping("work/scstocktran")
public class ScStocktranController {
    @Autowired
    private ScStocktranService scStocktranService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("work:scstocktran:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = scStocktranService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{stocktranid}")
    @RequiresPermissions("work:scstocktran:info")
    public R info(@PathVariable("stocktranid") String stocktranid){
		ScStocktranEntity scStocktran = scStocktranService.getById(stocktranid);

        return R.ok().put("scStocktran", scStocktran);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("work:scstocktran:save")
    public R save(@RequestBody ScStocktranEntity scStocktran){
		scStocktranService.save(scStocktran);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("work:scstocktran:update")
    public R update(@RequestBody ScStocktranEntity scStocktran){
		scStocktranService.updateById(scStocktran);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("work:scstocktran:delete")
    public R delete(@RequestBody String[] stocktranids){
		scStocktranService.removeByIds(Arrays.asList(stocktranids));

        return R.ok();
    }

}
